package com.fdw.smartexam_system.system.service.impl;

import com.fdw.smartexam_system.system.model.Question;
import com.fdw.smartexam_system.system.model.StudentAnswer;
import com.fdw.smartexam_system.system.repository.StudentAnswerRepository;
import com.fdw.smartexam_system.system.service.StudentAnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Optional;

@Service
public class StudentAnswerServiceImpl implements StudentAnswerService {

    @Autowired
    private StudentAnswerRepository repository;

    public StudentAnswer submitAnswer(StudentAnswer answer) {
        // TODO: 实现业务逻辑
        answer.setAnswerTime(LocalDateTime.now());
        return repository.save(answer);
    }

    public StudentAnswer getAnswerById(Long id) {
        // TODO: 实现业务逻辑
        // TODO: 实现业务逻辑
        Optional<StudentAnswer> byId = repository.findById(id);
        return byId.get();
    }
}
